<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
   /******************************************************************************
     Copyright:: 2020- IBM, Inc

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  *****************************************************************************/
-->

<html lang="en-US">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>For a 'combobox', 'aria-haspopup' must match the role of the combobox pop-up.</title>
</head>

<body>
    <main>

        <!-- pass case -->
        <div id="pass1">
            <input type="text" aria-autocomplete="list" aria-controls="owned_listbox"
                aria-activedescendant="selected_option" aria-label="Tag" role="combobox" aria-expanded="true"
                aria-haspopup="listbox">
        </div>
        <ul role="listbox" id="owned_listbox">
            <li role="option">Zebra</li>
            <li role="option" id="selected_option" aria-selected="true">Zoom</li>
        </ul>

        <!-- pass case -->
        <div id="pass2">
            <input type="text" aria-autocomplete="list" aria-controls="owned_listbox2"
                aria-activedescendant="selected_option2" aria-label="Tag" role="combobox" aria-expanded="true" 
                >
        </div>
        <ul role="listbox" id="owned_listbox2">
            <li role="option">Zebra</li>
            <li role="option" id="selected_option2">Zoom</li>
        </ul>

        <!-- fail case -->
        <div id="pass3">
            <input type="text" aria-autocomplete="list" aria-controls="owned_listbox3"
                aria-activedescendant="selected_option3" aria-label="Tag" role="combobox" aria-expanded="true" aria-owns="owned_listbox3"
                aria-haspopup="tree">
        </div>
        <ul role="listbox" id="owned_listbox3">
            <li role="option">Zebra</li>
            <li role="option" id="selected_option3">Zoom</li>
        </ul>

        <!--  pass case -->
        <label> Oh, my Chuck
            <input type="text" role="combobox" id="input3" aria-activedescendant="Chuck_option" aria-expanded="true"
                aria-owns="textbox3 list2" aria-controls="list2" aria-autocomplete="list" tabindex="0" list="list2"
                aria-haspopup="listbox">
        </label>
        <label> input box <input type="url" id="textbox3" aria-multiline="false" role="textbox"> </label>
        <ul aria-expanded="true" role="listbox" id="list2" onkeypress="keyEvent()" aria-label="list2">
            <li role="option" aria-selected="false" aria-label="Chuck option" id="Chuck_option" tabindex="0"
                aria-checked="undefined">Chuck</li>
            <li role="option" aria-selected="false" aria-label="Amara option" id="Amara_option" tabindex="0"
                aria-checked="mixed">Amara</li>
        </ul>
    </main>

    <script>
        UnitTest = {
            ruleIds: ["combobox_haspopup"],
            results: [{
            "ruleId": "combobox_haspopup",
            "value": [
              "INFORMATION",
              "PASS"
            ],
            "path": {
              "dom": "/html[1]/body[1]/main[1]/div[1]/input[1]",
              "aria": "/document[1]/main[1]/combobox[1]"
            },
            "reasonId": "Pass",
            "message": "The 'aria-controls' (WAI-ARIA 1.2) or 'aria-owns' (WAI-ARIA 1.0) appropriately references a valid popup 'id' value",
            "messageArgs": [],
            "apiArgs": [],
            "category": "Accessibility"
          },
          {
            "ruleId": "combobox_haspopup",
            "value": [
              "INFORMATION",
              "PASS"
            ],
            "path": {
              "dom": "/html[1]/body[1]/main[1]/div[2]/input[1]",
              "aria": "/document[1]/main[1]/combobox[2]"
            },
            "reasonId": "Pass",
            "message": "The 'aria-controls' (WAI-ARIA 1.2) or 'aria-owns' (WAI-ARIA 1.0) appropriately references a valid popup 'id' value",
            "messageArgs": [],
            "apiArgs": [],
            "category": "Accessibility"
          },
          {
            "ruleId": "combobox_haspopup",
            "value": [
              "INFORMATION",
              "FAIL"
            ],
            "path": {
              "dom": "/html[1]/body[1]/main[1]/div[3]/input[1]",
              "aria": "/document[1]/main[1]/combobox[3]"
            },
            "reasonId": "Fail_combobox_popup_role_mismatch",
            "message": "The value of the combobox 'aria-haspopup' attribute \"tree\" does not match the 'role' value of the popup element \"listbox\"",
            "messageArgs": [
              "tree",
              "listbox"
            ],
            "apiArgs": [],
            "category": "Accessibility"
          },
          {
            "ruleId": "combobox_haspopup",
            "value": [
              "INFORMATION",
              "PASS"
            ],
            "path": {
              "dom": "/html[1]/body[1]/main[1]/label[1]/input[1]",
              "aria": "/document[1]/main[1]/combobox[4]"
            },
            "reasonId": "Pass",
            "message": "The 'aria-controls' (WAI-ARIA 1.2) or 'aria-owns' (WAI-ARIA 1.0) appropriately references a valid popup 'id' value",
            "messageArgs": [],
            "apiArgs": [],
            "category": "Accessibility"
          }]
        }
    </script>
</body>

</html>